package com.cskaoyan.mall.model.vo.mall;

import java.io.DataOutputStream;
import java.util.List;

public class GetGoodsCommentVO {
    private List<GetCommentVO> commentList;
    private Double rate = 0.0;
    public GetGoodsCommentVO() {

    }
    public List<GetCommentVO> getCommentList() {
        return commentList;
    }

    public void setCommentList(List<GetCommentVO> commentList) {
        this.commentList = commentList;
        Double sum = 0.0;
        Double average = 0.0;
        if (commentList != null) {
            for (GetCommentVO comment : commentList) {
                sum += comment.getScore();
            }
            average = sum / commentList.size();
        }
        setRate(average);
    }

    public Double getRate() {
        return rate;
    }

    public void setRate(Double rate) {
        this.rate = rate;
    }

    public GetGoodsCommentVO(List<GetCommentVO> commentList) {
        this.commentList = commentList;
        Double sum = 0.0;
        Double average = 0.0;
        if (commentList != null) {
            for (GetCommentVO comment : commentList) {
                sum += comment.getScore();
            }
            average = sum / commentList.size();
        }
//        setRate(average);
        this.rate = average;
    }
}
